package com.zyy.command.demo01;

import java.util.Map;
import java.util.Set;

/**
 * @Description: 具体命令类
 */
public class OrderCommand implements Command {
    private SeniorChef seniorChef;
    private Order order;

    public OrderCommand(SeniorChef seniorChef, Order order) {
        this.seniorChef = seniorChef;
        this.order = order;
    }

    @Override
    public void execute() {
        System.out.println(order.getDiningTable() + "号桌的订单如下：");
        Map<String, Integer> foodDic = order.getFoodDic();
        Set<Map.Entry<String, Integer>> entries = foodDic.entrySet();
        for (Map.Entry<String, Integer> entry : entries) {
            seniorChef.makeFood(entry.getValue(), entry.getKey());
        }

        //模拟做饭，休眠1秒
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        System.out.println(order.getDiningTable() + "桌均已经上齐。。。");
    }
}
